Conversation
… properties - Implement `AnalyzeElementType` to correctly resolve path prefixes for collection elements. - Update `TypeMappingStrategyResolver` to include collection property paths in context. - Add `DM0008` diagnostic for invalid properties within collection element paths. - Enhance documentation with examples of collection element dot-notation mappings. - Include test cases validating dot-notation overrides for nested list, array, and dictionary elements.
…support - Extend documentation to clarify dot-notation usage for collection element properties. - Update `DM0008` diagnostic details with support for nested collection element paths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 Pull Request
📋 Summary
Fixes two bugs that prevented
[DynamoField]dot-notation overrides from working when an intermediate path segment is a collection (List<T>,T[],Dictionary<string, T>, etc.).Example that now works:
Bug 1 —
ValidatePath()inModelClassInfo.cstraversed directly intoList<CustomerContact>when resolving theContactssegment, causing a falseDM0008diagnostic. Fix: after the existing nullable unwrap, now also callsCollectionTypeAnalyzer.Analyze()to unwrap to the element type before advancing.Bug 2 —
CreateCollectionStrategy()inTypeMappingStrategyResolver.cscreated a freshNestedAnalysisContextwith an empty path, soGetFieldOptionsForProperty("VerifiedAt")looked up"VerifiedAt"instead of"Contacts.VerifiedAt". Additionally,CollectionTypeAnalyzer.ValidateElementType()calledNestedObjectTypeAnalyzer.Analyze()with the dummy property name"element", which further corrupted the path. Fix: a newAnalyzeElementType()method bypasses the path-append thatAnalyze()performs, and callers supply the correct path prefix up-front.The fix applies uniformly to
List<T>,T[],Dictionary<string, T>, and collections nested within nested objects.✅ Checklist
🧪 Related Issues or PRs
Closes #91
💬 Notes for Reviewers
Three source files changed:
ModelClassInfo.cs— 4-line addition inValidatePath(), no logic removedCollectionTypeAnalyzer.cs— swapAnalyze(..., "element", ...)for newAnalyzeElementType(...)NestedObjectTypeAnalyzer.cs— newinternal AnalyzeElementType()method + one-line change inAnalyzeForInline()to passcontextWithAncestor.WithPath(property.Name)for collection properties within nested objects6 new snapshot tests in
CollectionDotNotationVerifyTests.cscoverList<T>,T[],Dictionary<string, T>, multiple overrides on the same element type, and a DM0008 regression guard for invalid element property names.